1. Field of the Invention
The present invention relates to a control system and method of a data cache memory arranged between a central processing unit (CPU) and a main memory.
2. Description of the Related Art
With recent improvements in microcomputers, various microprocessors have been developed. For example, a 32-bit microprocessor was developed as such a microprocessor. Such a microprocessor, for example, the 32-bit microprocessor M68020 is available from Motorola Ltd., U.S.A. This microprocessor M68020 is provided with instructions (LINK and UNLINK instructions) for securing variables so that use of global and local variables is allowed. Such LINK and UNLINK instructions are described in, e.g., "MC68030 Enhanced 32 Bit Microprocessor Users Manual." A global variable can be accessed in an entire program, whereas a local variable can be accessed in only a certain module (task) constituting the program.
More specifically, the LINK and UNLINK instructions allocate and deallocate a certain area in a system stack, of a main memory respectively. The LINK and UNLINK instructions are used for a nested subroutine, a link list or a procedure. The LINK instruction is executed succeeding to a procedure call (a subroutine call to be nested). When the LINK instruction is executed, a pointer in an address register is updated to designate the data area. After the subroutine is executed, the UNLINK instruction is executed to perform an operation opposite to the LINK instruction. More specifically, the UNLINK instruction restores the stack pointer and the address register to previous values before the LINK instruction is executed. The details of the LINK and UNLINK instructions are described in "16-BIT MICROPROCESSOR User's Manual" by MOTOROLA.
However, in the prior art, since the local area is provided in the main memory, the processing speed is constrained to the memory cycle, resulting in low processing speed.
However, when an interruption is generated during execution of the program or task switching is performed during multitask processing, the contents of the cache memory must be rewritten in the main memory. That is, since the cache memory is a copy of part of the address space of the main memory, the contents of the cache memory must coincide with the contents of the corresponding area of the main memory. Therefore, when an interruption is generated or a task is switched, no problem is posed in the read operation with respect to the cache memory. When data is written in the cache memory, however, the data must be also written in the main memory. In this case, "write through", "copy back", or the like is used as a technique of writing data in the main memory. In the "write through" technique, data is written in the main memory immediately after the data is written in the cache memory. According to the "copy back" technique, a certain amount of data are preserved, and the preserved data are collectively written in the main memory later.
As described above, since the main memory is slower in writing speed than the cache memory, if data is written in the main memory every time an interruption is generated or a task is switched, overhead is inevitably increased. In a system having a conventional cache memory, a local area (having the same address space as that of the cache memory) is secured on the main memory, and local variables are stored in the local area. A necessary local variable is accessed using a stack pointer. In this case, if a local variable in the cache memory is updated, the corresponding data in the main memory must be updated, thereby degrading the high-speed operation of the overall system.